<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8"/>
    <link rel="apple-touch-icon" sizes="76x76" href="../static/assets/img/icons-taobao-48.png">
    <link rel="icon" type="image/png" href="../static/assets/img/icons-taobao-48.png">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}{% endblock %}</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <!--     字体和图标     -->
    <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet"/>
    <link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet">
    <!-- CSS 文件 -->
    <link href="../static/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../static/assets/css/now-ui-dashboard.min.css?v=1.0.1" rel="stylesheet"/>
    {% block css %}{% endblock %}
    <!-- CSS 仅用于演示目的，不要将其包含在您的项目中 -->
    <link href="../static/assets/demo/demo.css" rel="stylesheet"/>
</head>

<body class="">
<div class="wrapper ">
    <!-- 侧边栏 -->
    {% block Sidebar %}
    {% endblock %}
    <!-- 侧边栏结束 -->
    <div class="main-panel">
        <!-- 导航栏 -->
        <nav class="navbar navbar-expand-lg navbar-transparent  navbar-absolute bg-primary fixed-top">
            <div class="container-fluid">
                <div class="navbar-wrapper">
                    <div class="navbar-toggle">
                        <button type="button" class="navbar-toggler">
                            <span class="navbar-toggler-bar bar1"></span>
                            <span class="navbar-toggler-bar bar2"></span>
                            <span class="navbar-toggler-bar bar3"></span>
                        </button>
                    </div>
                    <a class="navbar-brand" href="#pablo" style="color: #1c84fc">{% block nav %}{% endblock %}</a>
                </div>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigation"
                        aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-bar navbar-kebab"></span>
                    <span class="navbar-toggler-bar navbar-kebab"></span>
                    <span class="navbar-toggler-bar navbar-kebab"></span>
                </button>
                <div class="collapse navbar-collapse justify-content-end" id="navigation">
                    <!-- 修改搜索框为 AI 回答框 -->
                    <form id="ai-form">
                        <div class="input-group no-border">
                            <input type="text" id="ai-input" class="form-control" placeholder="AI智能机器人...">
                            <span class="input-group-addon" id="submit-button">
                                <i class="now-ui-icons ui-1_zoom-bold"></i>
                            </span>
                        </div>
                    </form>
                    <ul class="navbar-nav">
                        <li class="nav-item">
                            <!-- 修改导航栏的注册|登录部分 -->
                            <ul class="navbar-nav">
                                {% if user %}
                                    <!-- 登录状态：显示用户名、头像和退出选项 -->
                                    <li class="nav-item dropdown">
                                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink"
                                           data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                            <img src="{{ user.avatar_url }}" class="rounded-circle" width="30"
                                                 height="30" alt="头像">
                                            {{ user.username }}
                                        </a>
                                        <div class="dropdown-menu dropdown-menu-right"
                                             aria-labelledby="navbarDropdownMenuLink">
                                            <a class="dropdown-item" href="{{ url_for('auth.logout') }}">退出登录</a>
                                        </div>
                                    </li>
                                {% else %}
                                    <!-- 未登录状态：显示注册/登录链接 -->
                                    <li class="nav-item">
                                        <a class="nav-link" href="{{ url_for('auth.login') }}">
                                            <i class="now-ui-icons users_single-02"></i>
                                            <p>
                                                <span class="d-lg-none d-md-block">注册 | 登录</span>
                                            </p>
                                        </a>
                                    </li>
                                {% endif %}
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
        <!-- 结束导航栏 -->

        <!-- 内容 -->
        {% block content %}
        {% endblock %}
        <!-- 内容结束 -->
        <!-- 页脚 -->
        <footer class="footer">
            <div class="container-fluid">
                <nav>
                    <ul>
                        <li>
                            <div href="#">
                                客服热线：400-34566543
                            </div>
                        </li>
                        <li>
                            <div href="#">
                                客服邮箱：kefu@xitong.com.cn
                            </div>
                        </li>
                    </ul>
                </nav>
                <div class="copyright">
                    &copy;
                    <script>
                        document.write(new Date().getFullYear())
                    </script>
                    ,taobao.com 版权所有
                    淘ICP备11111111号-1
                    淘公网安备22222222号
                </div>
            </div>
        </footer>
    </div>
</div>
</body>
<!--   核心 JS 文件   -->
<script src="../static/assets/js/jquery.min.js"></script>
<script src="../static/assets/js/core/popper.min.js"></script>
<script src="../static/assets/js/core/bootstrap.min.js"></script>
<script src="../static/assets/js/plugins/perfect-scrollbar.jquery.min.js"></script>
{% block js %}{% endblock %}
<!--  Google Maps Plugin    -->
<!-- 图表 JS -->
<script src="../static/assets/js/plugins/chart.js"></script>
<!--  通知插件    -->
<script src="../static/assets/js/plugins/bootstrap-notify.js"></script>
<!-- now Ui 仪表板的控制中心：视差效果、示例页面的脚本等。 -->
<script src="../static/assets/js/now-ui-dashboard.js?v=1.0.1"></script>
<!-- now Ui 仪表板演示方法，不要将其包含在你的项目中！ -->
<script src="../static/assets/demo/demo.js"></script>
<script>
    $(document).ready(function () {
        // JavaScript 方法的代码可以在 assets/js/demos.js 中找到。
        demo.initDashboardPageCharts();
    });
</script>
<script>
    $(document).ready(function () {
        // JavaScript 方法的代码可以在 assets/js/demos.js 中找到。
        demo.initGoogleMaps();
    });
</script>
<!--  AI    -->
<script>
    // 为 <span> 添加点击事件监听器
    document.getElementById('submit-button').addEventListener('click', function () {
        document.getElementById('ai-form').dispatchEvent(new Event('submit'));
    });

    // 表单提交事件
    document.getElementById('ai-form').addEventListener('submit', function (event) {
        event.preventDefault();
        const userInput = document.getElementById('ai-input').value;

        // 跳转到 answer.html 页面，并将用户输入的问题作为 URL 参数传递
        window.location.href = `/answer.html?question=${encodeURIComponent(userInput)}`;
    });
</script>

</html>
